<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<!--
`paper-slider` allows user to select a value from a range of values by
moving the slider thumb.  The interactive nature of the slider makes it a 
great choice for settings that reflect intensity levels, such as volume, 
brightness, or color saturation.

Example:

    <paper-slider></paper-slider>

Use `min` and `max` to specify the slider range.  Default is 0 to 100.

Example:

    <paper-slider min="10" max="200" value="110"></paper-slider>

Styling slider:

To change the slider progress bar color:

    paper-slider::shadow #sliderBar::shadow #activeProgress {
      background-color: #0f9d58;
    }

To change the slider knob color:

    paper-slider::shadow #sliderKnobInner {
      background-color: #0f9d58;
    }

To change the slider pin color:

    paper-slider::shadow #sliderKnobInner::before {
      background-color: #0f9d58;
    }

To change the slider pin's value:

    paper-slider::shadow #sliderKnobInner::after {
      color: #0f9d58
    }

To change the slider secondary progress bar color:

    paper-slider::shadow #sliderBar::shadow #secondaryProgress {
      background-color: #0f9d58;
    }

@group Paper Elements
@element paper-slider
@extends core-range
@homepage github.io
-->

<link rel="import" href="../core-a11y-keys/core-a11y-keys.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../paper-input/paper-input.html">

<polymer-element name="paper-slider" extends="core-range" attributes="snaps pin disabled secondaryProgress editable immediateValue" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100">
<template>

  <link rel="stylesheet" href="paper-slider.css">

  <template if="{{!disabled}}">
    <core-a11y-keys target="{{}}" keys="left down pagedown home" on-keys-pressed="{{decrementKey}}"></core-a11y-keys>
    <core-a11y-keys target="{{}}" keys="right up pageup end" on-keys-pressed="{{incrementKey}}"></core-a11y-keys>
  </template>

  <div id="sliderContainer" class="{{ {disabled: disabled, pin: pin, snaps: snaps, ring: immediateValue <= min, expand: expand, dragging: dragging, transiting: transiting, editable: editable} | tokenList }}">

    <div class="bar-container">
      <paper-progress id="sliderBar" aria-hidden="true" min="{{min}}" max="{{max}}" value="{{immediateValue}}" secondaryProgress="{{secondaryProgress}}"
          on-down="{{bardown}}" on-up="{{resetKnob}}" 
          on-trackstart="{{trackStart}}" on-trackx="{{trackx}}" on-trackend="{{trackEnd}}"></paper-progress>
    </div>

    <template if="{{snaps && !disabled}}">
      <div class="slider-markers" horizontal layout>
        <template repeat="{{markers}}">
          <div flex class="slider-marker"></div>
        </template>
      </div>
    </template>

    <div id="sliderKnob" on-down="{{expandKnob}}" on-up="{{resetKnob}}"
        on-trackstart="{{trackStart}}" on-trackx="{{trackx}}" on-trackend="{{trackEnd}}"
        on-transitionend="{{knobTransitionEnd}}"
        center-justified center horizontal layout>

      <div id="sliderKnobInner" value="{{immediateValue}}"></div>

    </div>

  </div>

  <template if="{{editable}}">
    <paper-input id="input" class="slider-input" value="{{immediateValue}}" disabled?="{{disabled}}" on-change="{{inputChange}}"></paper-input>
  </template>

</template>
<script src="paper-slider.js"></script>
</polymer-element>
